//
//  LoginView.m
//
//  Created by David Hinson on 10/9/08.
//  Copyright 2009 Cliqset, Inc.. All rights reserved.
//

#import "LoginView.h"
#import "cliqsetAppDelegate.h"

@implementation LoginView

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}

-(IBAction)cancelView:(id)sender {
	
	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

	cliqsetAppDelegate* myApp = (cliqsetAppDelegate*)[[UIApplication sharedApplication] delegate];
	
	NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
	[standardUserDefaults synchronize];

	if (!myApp.isAuthenticated) {
		[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
		[myApp addTextToLog:@"Please re-enter your Login and Password" withCaption:@"Invalid Login"];
	} else {
		[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
		[myApp flipLoginToBack];
	}
}

-(IBAction)tellDelegateToFlipViews:(id)sender {
	
	cliqsetAppDelegate* myApp = (cliqsetAppDelegate*)[[UIApplication sharedApplication] delegate];
	
	NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
	[standardUserDefaults synchronize];
	
	[myApp showEventsHoverView:YES];
		
	myApp.loginString = [[NSUserDefaults standardUserDefaults] stringForKey:@"loginKey"];
	myApp.passwordString = [[NSUserDefaults standardUserDefaults] stringForKey:@"passwordKey"];
	[myApp.cliqset authenticate];
	[myApp flipLoginToBack];
}


- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (void)dealloc {
    [super dealloc];
}


@end
